package cn.cs.service;

import cn.cs.mapper.ShoppingCarMapper;
import cn.cs.pojo.CarProductList;
import cn.cs.pojo.ShoppingCart;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
public class ShoppingCarService {
    @Resource
    private ShoppingCarMapper mapper;
    @RequestMapping(value = "/getShopCartByMap", method = RequestMethod.POST)
    @Transactional
    ShoppingCart getShopCartByMap(@RequestBody Map<String, Object> map){
        return mapper.getShopCartByMap(map);
    }
    @RequestMapping(value = "/insertShoppingCart", method = RequestMethod.POST)
    @Transactional
    int insertShoppingCart(@RequestBody ShoppingCart shopCar){
        return mapper.insertShoppingCart(shopCar);
    }
    @RequestMapping(value = "/deleteOtherShopCar", method = RequestMethod.POST)
    int deleteOtherShopCar(@RequestBody Map<String, Object> param){
        return mapper.deleteOtherShopCar(param);
    }
    @RequestMapping(value = "/getProCountOfCar", method = RequestMethod.POST)
    @Transactional
    Map<String,Object> getProCountOfCar(@RequestBody Map<String, Object> param){
        return mapper.getProCountOfCar(param);
    }
    @RequestMapping(value = "/updateCarProductCount", method = RequestMethod.POST)
    @Transactional
    int updateCarProductCount(@RequestBody Map<String, Object> param){
        return mapper.updateCarProductCount(param);
    }
    @RequestMapping(value = "/insertCarProductList", method = RequestMethod.POST)
    @Transactional
    int insertCarProductList(@RequestBody CarProductList pro){
        return mapper.insertCarProductList(pro);
    }
    @RequestMapping(value = "/getProshops", method = RequestMethod.POST)
    @Transactional
    List<Map<String,Object>> getProshops(@RequestBody Map<String, Object> para){
        return mapper.getProshops(para);
    }
    @RequestMapping(value = "/getProsByMap", method = RequestMethod.POST)
    @Transactional
    List<Map<String,Object>> getProsByMap(@RequestBody Map<String, Object> para){
        return mapper.getProsByMap(para);
    }
    @RequestMapping(value = "/getCarProductListListByMap", method = RequestMethod.POST)
    @Transactional
    List<CarProductList> getCarProductListListByMap(@RequestBody Map<String, Object> map){
        return mapper.getCarProductListListByMap(map);
    }
    @RequestMapping(value = "/getShopsByProIds", method = RequestMethod.POST)
    @Transactional
    List<Map<String,Object>> getShopsByProIds(@RequestBody Map<String, Object> param){
        return mapper.getShopsByProIds(param);
    }
    @RequestMapping(value = "/deleteCarProductListById", method = RequestMethod.POST)
    @Transactional
    int deleteCarProductListById(@RequestParam("id") String id){
        return mapper.deleteCarProductListById(id);
    }
    @RequestMapping(value = "/updateCarProductList", method = RequestMethod.POST)
    @Transactional
    int updateCarProductList(@RequestBody CarProductList pro){
        return mapper.updateCarProductList(pro);
    }
}
